package com.morder.net;

import org.apache.http.HttpHost;
import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.conn.params.ConnRouteParams;
import org.apache.http.impl.client.DefaultHttpClient;

final class ClientUtils {
  private ClientUtils() {
  }

  public static DefaultHttpClient applyApn(DefaultHttpClient client, Apn apn) {
    if(!Apn.isUnValid(apn)) {
      HttpHost proxy = new HttpHost(apn.getProxy(), apn.getPort());
      client.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, proxy);
    }
    return client;
  }

  public static DefaultHttpClient removeApn(DefaultHttpClient client) {
    client.getParams().removeParameter(ConnRoutePNames.DEFAULT_PROXY);
    return client;
  }

}
